<%--
  Created by IntelliJ IDEA.
  User: id
  Date: 2021/1/23
  Time: 8:49
  To change this template use File | Settings | File Templates.
--%>
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<%@ page  isELIgnored="false" contentType="text/html;charset=UTF-8" language="java" %>
<%@include file="../util/makerAndenterGoodAndselect1.jsp"%>
<html>
<head>
    <title>ADD Re</title>
    <style type="text/css">
        #add{
            width: 1288px;
            height:1000px;
            position: absolute;
            top: 60px;
            left: 83px;
        }

        .fr{
            width: 400px;
            height: 300px;
            position: relative;
            left: 480px;
            top: 50px;
        }
        span{
            color: cadetblue;
        }
        input{
            text-align: center;
        }
    </style>
    <script type="text/javascript" src="../../../static/jquery-3.4.1.js"></script>
    <script type="text/javascript">
        $(function () {
            $("#add").hover(function () {
                    $("#d3").hide()
                    $("#xs").hide()
                    $("#d2").hide()
                    $("#d4").hide()
                }
            )

            /*效验*/
            var fl=true;
            var re =/[\u4e00-\u9fa5]/;  //中文
            var reg = /^[0-9]+.?[0-9]*$/;           //数字
            var reg2 = /^[A-Za-z]+$/ //字母
            var reg3 = /^(?!\d+$)(?![a-zA-Z]+$)[a-zA-Z\d]+$/ //;//字母和数字

            var name=$("#rName").val();
            if(name==null || name==""){
                $("#s1").html("×")
                fl=false
            } else {
                $("#s1").html("√")
                fl=true
            }

            /*ajax*/
            var path=$("#path").val();
            $("#rName").blur(function () {
                if($("#rName")==null||$("#rName").val()==""){
                    $("#s1").html("请填写仓库名称")
                    fl=false;
                }else if(reg.test($("#rName").val())){
                    $("#s1").html("名称不能为数字")
                    fl=false;
                } else {
                    var rName = $("#rName").val();
                    $.getJSON(path+"/Repository/ADDRES2", {name:rName}, function (data) {
                        if (data.userCode == "exist") {
                            $("#s1").html("×");
                            $("#s11").html("库名存在!");
                            fl=false;
                        } else if (data.userCode == "no") {
                            $("#s1").html("√");
                            $("#s11").html("库名可添加");
                            fl=true;
                        }
                    })
                }
            })


            /*表单验证*/
            $("Form").submit(function () {
                return fl;
            })

        })
    </script>
</head>
<body>
<input type="hidden" id="path" value="${pageContext.request.contextPath}">
<div id="add">
    <div class="fr">
        <form action="${pageContext.request.contextPath}/Repository/ADDRE">
            <span>仓库名称:</span>
            <input type="text" name="rName" style="width: 170px;height: 30px;border-radius: 6px" id="rName">
            <span id="s1" style="color: red"></span>
            <span id="s11"style="color: red"></span>
            <br><br>
            &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
            <input type="submit" value="Add to" style="width: 170px;height: 30px;border-radius: 6px">
        </form>
    </div>
</div>
</body>
</html>
